import { delToken, getToken, getuser, setToken, setuser } from '@/utils/storage'
// import { getUser } from '@/api/user.js'
// import { setToken } from '@/utils/storage'
export default {
  namespaced: true,
  state () {
    return {
      // 一进页面从本地获取到token
      token: getToken(),
      user: JSON.parse(getuser())
    }
  },
  mutations: {
    usersetToken (state, payload) {
      state.token = payload.token
      // console.log('打印')
      // console.log(payload)
      setToken(payload.token)
      // console.log(JSON.stringify(payload))
      state.user = payload
      setuser(JSON.stringify(payload))
    },
    userdelToken (state) {
      // 删除token
      state.token = ''
      delToken()
    }
  },
  actions: {
    // getUser (ctx, payload) {
    //   console.log(ctx, payload)
    //   getUser()
    // }
  },
  getters: {}
}
